<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<link rel="stylesheet" type="text/css" href="boost.css">
<title>Boost.Numeric.Bindings</title>
</head>

<body link="#0000ff" vlink="#800080">
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary="header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Numeric.Bindings</h1>
<h2 align="center">Index</h2>
</td>
</tr>
</table>

<hr>

<h2>Synopsis</h2>

<p>The Bindings Library contains bindings to popular non-boost 
(numeric) libraries, usually written in Fortran or C. 
These non-boost libraries generally use data structures in their API for which
there might be boostified equivalents or other popular non-boost equivalents.
The Bindings Library offers a generic thin layer API on top of the 
original API of the external library. This generic API accepts a whole range of
data structures from different origins and usually hides or reduces the complexity of the original API. 

<p>For instance, <a
href="http://math-atlas.sourceforge.net/">ATLAS</a>, a C library
implementing BLAS (and few LAPACK routines), represents matrices by means of a pointer and the dimensions. Now boost also contains
matrix classes (<a href="http://www.boost.org/libs/numeric/ublas/doc/index.htm">uBLAS</a>) and there are also other matrix libraries in widespread use. Therefore the Bindings
library features a <a href="../atlas/doc/index.html">generic interface for ATLAS</a> which provides the possibility
to call e.g. the matrix-multiplication routine of ATLAS using matrices defined
in uBLAS, <a href="http://math.nist.gov/tnt/index.htm">TNT</a>, etc.: 

<pre class="programlisting">
  #include &lt;boost/numeric/bindings/traits/ublas_matrix.hpp&gt;
  #include &lt;boost/numeric/bindings/traits/tnt.hpp&gt;
  #include &lt;boost/numeric/bindings/atlas/cblas3.hpp&gt; 

  namespace ublas = boost::numeric::ublas; 
  namespace atlas = boost::numeric::bindings::atlas;

  int main() {
    ublas::matrix&lt;double&gt; A1 (2,2), B1 (2,3), C1 (2,3);
    // initialisation... 
    // C1 &lt;- A1 * B1 :
    atlas::gemm (A1, B1, C1); 

    ublas::matrix&lt;double, ublas::column_major&gt; A2 (2,3), B2 (2,2), C2 (3,2);
    // ... 
    // C2 &lt;- A2^T * B2^T : 
    atlas::gemm (CblasTrans, CblasTrans, 1.0, A2, B2, 0.0, C2);

    TNT::Array2D&lt;double&gt; A3 (2,2), B3 (2,3), C3 (2, 3); 
    // ...
    // C3 &lt;- A3^T * B3 :
    atlas::gemm (CblasTrans, CblasNoTrans, 1.0, A3, B3, 0.0, C3);

    TNT::Fortran_Array2D<double> A4 (2,2), B4 (2,3), C4 (2, 3);
    // ... 
    // C4 &lt;- 2.0 * A4 * B4 + C4 :
    atlas::gemm (2.0, A4, B4, 1.0, C4); 
  }
</pre>

In short, <code>gemm()</code> is BLAS/ATLAS matrix multiplication
function. <a href="../atlas/doc/index.html">ATLAS bindings</a> provide
three convenient overloads:  
<pre>
  C &lt;- a * op (A) * op (B) + b * C
  C &lt;- a * A * B + b * C 
  C &lt;- A * B 
</pre>
where <code>a</code>, <code>b</code> are scalars, 
<code>A</code>, <code>B</code>, <code>C</code> are (rectangular) matrices and 
<code>op (A)</code> == <code>A</code> || <code>A</code><sup>T</sup> || <code>A</code><sup>H</sup>. 
Function <code>gemm()</code> is BLAS level 3 routine and therefore
<code>atlas/cblas3.hpp</code> should be included (all headers
are in subdirectories of <code>boost/numeric/bindings</code>). 
To use bindings with <code>ublas::matrix&lt;&gt;</code> one should
include <code>traits/ublas_matrix.hpp</code> (note that there is no
need to include <code>boost/numeric/ublas/matrix.hpp</code>
separately) and to use them with TNT
arrays <code>traits/tnt.hpp</code> should be included; to learn more
about traits classes see chapter <a href="../traits/doc/index.html">Traits</a>.

<br><br>
<hr>

<h2>Contents</h2>
<dl class="index">
<dt><a href="../traits/doc/index.html">Traits</a></dt>
<dt>Amos bindings</dt>
<dt><a href="../atlas/doc/index.html">ATLAS bindings</a></dt>
<dt><a href="../blas/doc/index.html">BLAS bindings</a></dt>
<dt><a href="../lapack/doc/index.html">LAPACK bindings</a></dt>
<dt><a href="../umfpack/doc/index.html">UMFPACK bindings</a></dt>
</dl>

</body>
</html>
